import json


dic =\
{
    'name': 'qiu qiu',
    'age': 18,
}

# 1 文件位置
# with open('./111.txt') as f:
#     pass
# with open('D:/1/111.txt', 'w', encoding='utf-8') as f: '''绝对路径'''
with open('111.txt', 'w', encoding='utf-8') as f: # 相对路径
    json_str = json.dumps(dic)
    f.write(json_str)

    print('成功写入')

    pass